package com.itheima.stock.security.user;

import com.itheima.stock.pojo.domain.PermissionsTreeDomain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.bytebuddy.agent.builder.AgentBuilder;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * 自定义用户详情对象类
 */
@Data
public class LoginUserDetail implements UserDetails {

    private String username;

    private String password;

    private List<GrantedAuthority> authorities;

    /**
     * 账户是否没有过期
     */
    private boolean isAccountNonExpired=true;

    /**
     * true:账户没有锁定
     */
    private boolean isAccountNonLocked=true;

    /**
     * true:密码没有过期
     */
    private boolean isCredentialsNonExpired=true;

    /**
     * 账户是否可用
     */
    private boolean isEnabled=true;


    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id", position = 1)
    private Long id;

    /**
     * 电话号码
     */
    @ApiModelProperty(value = "电话号码", position = 3)
    private String phone;

    /**
     * 昵称
     */
    @ApiModelProperty(value = "昵称", position = 4)
    private String realName;

    /**
     * 性别
     */
    @ApiModelProperty(value = "性别", position = 5)
    private Integer sex;

    /**
     * 装填
     */
    @ApiModelProperty(value = "装填", position = 6)
    private Integer status;

    /**
     * 邮件
     */
    @ApiModelProperty(value = "邮件", position = 7)
    private String email;

    /**
     * 权限数（不包含按钮权限）
     */
    @ApiModelProperty(value = "权限数（不包含按钮权限）", position = 8)
    private List<PermissionsTreeDomain> menus;

    /**
     * 按钮权限集合
     */
    @ApiModelProperty(value = "按钮权限集合", position = 9)
    private List<String> permissions;


//    @Override
//    public Collection<? extends GrantedAuthority> getAuthorities() {
//        return null;
//    }

//    @Override
//    public String getPassword() {
//        return null;
//    }

//    @Override
//    public String getUsername() {
//        return null;
//    }

//    @Override
//    public boolean isAccountNonExpired() {
//        return false;
//    }

//    @Override
//    public boolean isAccountNonLocked() {
//        return false;
//    }
//
//    @Override
//    public boolean isCredentialsNonExpired() {
//        return false;
//    }
//
//    @Override
//    public boolean isEnabled() {
//        return false;
//    }
}
